import frida  

# 尝试连接到指定的设备和端口
try:  
    # rdev = frida.get_remote_device()  # 连接到可用的远程设备
    rdev = frida.get_usb_device()  # 如果是 USB 连接时可以使用此方法  

    # 枚举所有的进程
    processes = rdev.enumerate_processes()  
    for process in processes:  
        print(process)  

    # 获取在前台运行的APP
    front_app = rdev.get_frontmost_application()  
    print(front_app)  

except Exception as e:  
    print(f"An error occurred: {e}")
# Application(identifier="com.kugou.android", name="酷狗音乐", pid=12954, parameters={})
# Application(identifier="com.facebook.katana", name="Facebook", pid=23370, parameters={})
# Application(
    # identifier="com.chaozh.iReaderFree15", name="爱读掌阅", pid=1660, parameters={}
# )
# Application(identifier="com.myzaker.ZAKER_Phone", name="ZAKER", pid=13688, parameters={})